import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        System.out.println("请输入一个数：");
        int num = sc.nextInt();
        int count = 0;
        while(num > 0){
            num = num&(num-1);
            count++;
        }
        System.out.println("二进制1的个数：" + count);
    }
    /*public static void main5(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入两个整数：");
        int m = sc.nextInt();
        int n = sc.nextInt();
        int k = (m>n)?n:m;
        while(k>0) {
            if(m%k==0 && n%k ==0){
                System.out.println("最大公约数为：" + k);
                break;
            }
        }
    }*/
    /*public static void main4(String[] args) {
        double sum1 = 0;
        double sum2 = 0;
        double sum = 0;
        for (int i = 1; i <= 100; i++) {
            if(i % 2 == 0) {
                sum1 = (1.0 / i) + sum1;//偶数
            }else {
                sum2 = sum2 + (1.0 / i); //奇数
            }
        }
        sum = sum2 - sum1;
        System.out.println("结果："+sum);
    }*/
    /*public static void main3(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        int n = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            int hundreds = i / 100;
            int tens = (i/10) % 10;
            int units = i % 10;
            if (Math.pow(hundreds,3)+Math.pow(tens,3)+Math.pow(units,3) == i) {
                System.out.println(i);
            }
        }
    }*/
    /*public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数：");
        int j = sc.nextInt();
        for (int i = 2; i < j; i++) {
            if(j%i == 0){
                System.out.println("不是素数");
                break;
            }else{
                System.out.println("是素数");
                break;
            }
        }
    }*/
    /*public static void main1(String[] args) {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            int tens = i / 10;
            int units = i % 10;
            if(tens==9)count++;
            if(units==9)count++;
        }
        System.out.println("数字9出现的次数是："+count);
    }*/
}


